﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication1
{
    public class Person
    {
        public int ID { get; set; }
        public string Name { get; set; }
        private int _age;
        public int Age
        {
            get { return _age; }
            set
            {
                _age  =(value <= 120 || value >= 0) ? value :  0;
            }
        }
        /// <summary>
        /// 重写ToString()方法，输出Person类信息
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return string.Format("ID：{0}，Name：{1}，Age：{2}", ID, Name, Age);
        }

    }
}